<?php
/**
 * Created by xun at 2020/5/17
 */

namespace app\base;


use app\storage\Singleton;

class Queue
{

    use Singleton;

    private $lenth = 0;
    private $size;

    private $channel;

    public function __construct($size = 64 * 1024)
    {
        $this->channel = new \Swoole\Channel($size);
    }

    public function push($id)
    {
        $this->channel->push($id);
        $this->lenth++;
    }

    public function pop() {
        $id = $this->channel->pop();
        $this->lenth--;
        return $id;
    }

}